package me.codeleep.deepcode.core.dao.repository;

import me.codeleep.deepcode.core.dao.mapper.RootDirectoryMapper;
import me.codeleep.deepcode.core.dao.model.RootDirectory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository
public class RootDirectoryRepository {

    @Autowired
    private RootDirectoryMapper rootDirectoryMapper;

    public int saveRootDirector(RootDirectory rootDirectory) {
        if (rootDirectory == null) {
            return 0;
        }
        if (rootDirectory.getId() == null) {
            return rootDirectoryMapper.insert(rootDirectory);
        }
        return rootDirectoryMapper.updateById(rootDirectory);
    }

}
